﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;

namespace CommunitySystemModel
{
    [Serializable]
    [DataContract]
    public class Emp_EducationModel
    {
        private int _ID;
        [DataMember]
        public int ID
        {
            get { return _ID; }
            set { _ID = value; }
        }

        private int _EmpBasicID;
        [DataMember]
        public int EmpBasicID
        {
            get { return _EmpBasicID; }
            set { _EmpBasicID = value; }
        }

        private string _EducationName = string.Empty;
        [DataMember]
        public string EducationName
        {
            get { return _EducationName; }
            set { _EducationName = value; }
        }

        private string _EducationType = string.Empty;
        [DataMember]
        public string EducationType
        {
            get { return _EducationType; }
            set { _EducationType = value; }
        }

        private string _EducationaSystem = string.Empty;
        [DataMember]
        public string EducationaSystem
        {
            get { return _EducationaSystem; }
            set { _EducationaSystem = value; }
        }

        private DateTime? _GraduationDate = null;
        [DataMember]
        public DateTime? GraduationDate
        {
            get { return _GraduationDate; }
            set { _GraduationDate = value; }
        }

        private string _School = string.Empty;
        [DataMember]
        public string School
        {
            get { return _School; }
            set { _School = value; }
        }

        private string _Professional = string.Empty;
        [DataMember]
        public string Professional
        {
            get { return _Professional; }
            set { _Professional = value; }
        }

        private bool _IsTopEducation = false;
        [DataMember]
        public bool IsTopEducation
        {
            get { return _IsTopEducation; }
            set { _IsTopEducation = value; }
        }

        private string _IsTopEducationString = string.Empty;
        [DataMember]
        public string IsTopEducationString
        {
            get { return _IsTopEducationString; }
            set { _IsTopEducationString = value; }
        }

        private string _EmpName = string.Empty;
        [DataMember]
        public string EmpName
        {
            get { return _EmpName; }
            set { _EmpName = value; }
        }

        private string _EmpNo = string.Empty;
        [DataMember]
        public string EmpNo
        {
            get { return _EmpNo; }
            set { _EmpNo = value; }
        }

        public static Emp_EducationModel FillEntity(DataRow dr)
        {
            Emp_EducationModel right = new Emp_EducationModel();
            right.ID = (int)dr["ID"];
            right.EmpBasicID = (int)dr["EmpBasicID"];
            right.EducationName = dr["EducationName"] as string;
            right.EducationType = dr["EducationType"] as string;
            right.EducationaSystem = dr["EducationaSystem"] as string;
            right.EmpName = dr["EmpName"] as string;
            right.EmpNo = dr["EmpNo"] as string;
            if (!string.IsNullOrEmpty(dr["IsTopEducation"].ToString())) right.IsTopEducation = (bool)dr["IsTopEducation"];
            right.School = dr["School"] as string;
            right.Professional = dr["Professional"] as string;
            right.GraduationDate = (string.IsNullOrEmpty(dr["GraduationDate"].ToString()) || dr["GraduationDate"].ToString() == "1900/1/1 0:00:00") ? null : (DateTime?)dr["GraduationDate"];
            right.IsTopEducationString = dr["IsTopEducationString"] as string;
            return right;
        }
    }
}
